#%%
from configure import *
from glob import glob
from netCDF4 import Dataset


class DATA:

    def __init__(self, f, prod):
        self.lond = f.variables['lond'][:]
        self.latd = f.variables['latd'][:]
        self.__dict__[prod] = f.variables[prod][:]
        self.tflag = f.variables['TFLAG'][:]


def read_group(sat_var, group_n, res):
    _group_path = f'{data_path}/{res}_GEMS_{sat_var}_group'

    _fname = glob(f'{_group_path}/*_{group_n}.nc')[0]
    print(f'Read {_fname}')
    with Dataset(_fname, 'r') as _f:
        _data = DATA(_f, sat_var)
    return _data
